package com.dragon.pear.modules.admin.web.model.result;

import com.dragon.pear.modules.admin.web.model.data.LongCodeData;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author Chris Chan
 * Create On 2025/8/26 下午5:43
 * Use for: 购物车 参数
 * Explain:
 */
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "用户基本信息 结果")
public class UserBaseInfoResult extends LongCodeData implements Serializable {
    private static final long serialVersionUID = 1L;

    // 主键
    @Schema(description = "主键", example = "1")
    private Long id;

    @Schema(description = "用户名", example = "chris")
    private String username;

    // 数量
    @Schema(description = "权限列表")
    private List<String> roles;

    public UserBaseInfoResult(Long code, Long id, String name, List<String> roles) {
        super(code);
        this.id = id;
        this.username = username;
        this.roles = roles;
    }

    public UserBaseInfoResult(Long code, Long id, String username, String... roles) {
        super(code);
        this.id = id;
        this.username = username;
        this.roles = Stream.of(roles).collect(Collectors.toList());
    }

    public static UserBaseInfoResult create(Long code, Long id, String name, List<String> roles) {
        return new UserBaseInfoResult(code, id, name, roles);
    }

    public static UserBaseInfoResult of(Long code, Long id, String name, List<String> roles) {
        return new UserBaseInfoResult(code, id, name, roles);
    }

    public static UserBaseInfoResult create(Long code, Long id, String name, String... roles) {
        return new UserBaseInfoResult(code, id, name, roles);
    }

    public static UserBaseInfoResult of(Long code, Long id, String name, String... roles) {
        return new UserBaseInfoResult(code, id, name, roles);
    }

}
